package cn.tedu.csms.product.controller;


import cn.tedu.csms.base.response.JsonResult;
import cn.tedu.csms.product.pojo.dto.DeleteParam;
import cn.tedu.csms.product.pojo.dto.ProductQuery;
import cn.tedu.csms.product.pojo.dto.ProductSaveParam;
import cn.tedu.csms.product.pojo.dto.StorageParam;
import cn.tedu.csms.product.pojo.vo.ProductVO;
import cn.tedu.csms.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
@RequestMapping("/v1/product")
public class ProductController {
    @Autowired
    ProductService productService;


    @GetMapping("select")
    public JsonResult selectProduct( ProductQuery productQuery){
        log.debug("查询产品,参数{}",productQuery);
        List<ProductVO> list=productService.selectProduct(productQuery);
        return  JsonResult.ok(list);


    }

    @PostMapping("save")
    public JsonResult saveProduct(  ProductSaveParam productSaveParam){
        log.debug("保存产品,参数1 {},参数2 {}",productSaveParam);
        productService.saveProduct(productSaveParam);

        return JsonResult.ok();
    }
    @PostMapping("delete")
    public JsonResult deleteProduct(DeleteParam deleteParam){
        deleteParam.setId(deleteParam.getGoodsId());
        log.debug("删除产品库存,产品参数{}",deleteParam);
       productService.deleteProduct(deleteParam);
        return JsonResult.ok();
    }





}
